package com.codegeek.project.slope.controller;

import com.codegeek.common.utils.poi.ExcelUtil;
import com.codegeek.framework.aspectj.lang.annotation.Log;
import com.codegeek.framework.aspectj.lang.enums.BusinessType;
import com.codegeek.framework.web.controller.BaseController;
import com.codegeek.framework.web.domain.AjaxResult;
import com.codegeek.framework.web.page.TableDataInfo;
import com.codegeek.project.slope.domain.SlopeMesh;
import com.codegeek.project.slope.service.ISlopeMeshService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 三维模型Controller
 *
 * @author codegeek
 * @date 2020-02-17
 */
@RestController
@RequestMapping("/slope/mesh")
@Api(value="三维模型Controller",tags={"三维模型操作接口"})
public class SlopeMeshController extends BaseController
{
    @Autowired
    private ISlopeMeshService slopeMeshService;

    /**
     * 查询三维模型列表
     */
    @ApiOperation("查询三维模型列表")
    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('slope:mesh:list')")
    public TableDataInfo list(SlopeMesh slopeMesh)
    {
        startPage();
        List<SlopeMesh> list = slopeMeshService.selectSlopeMeshList(slopeMesh);
        return getDataTable(list);
    }

    /**
     * 导出三维模型列表
     */
    @ApiOperation("导出三维模型列表")
    @Log(title = "监测管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @PreAuthorize("@ss.hasPermi('slope:mesh:export')")
    public AjaxResult export(SlopeMesh slopeMesh)
    {
        List<SlopeMesh> list = slopeMeshService.selectSlopeMeshList(slopeMesh);
        ExcelUtil<SlopeMesh> util = new ExcelUtil<SlopeMesh>(SlopeMesh.class);
        return util.exportExcel(list, "mesh");
    }

    /**
     * 获取三维模型详细信息
     */
    @ApiOperation("获取三维模型详细信息")
    @GetMapping(value = "/{meshId}")
    @PreAuthorize("@ss.hasPermi('slope:mesh:getInfo')")
    public AjaxResult getInfo(@PathVariable("meshId") Long meshId)
    {
        return AjaxResult.success(slopeMeshService.selectSlopeMeshById(meshId));
    }

    /**
     * 新增三维模型
     */
    @ApiOperation("新增三维模型")
    @Log(title = "监测管理", businessType = BusinessType.INSERT)
    @PostMapping
    @PreAuthorize("@ss.hasPermi('slope:mesh:add')")
    public AjaxResult add(@RequestBody SlopeMesh slopeMesh)
    {
        return toAjax(slopeMeshService.insertSlopeMesh(slopeMesh));
    }

    /**
     * 修改三维模型
     */
    @ApiOperation("修改三维模型")
    @Log(title = "监测管理", businessType = BusinessType.UPDATE)
    @PostMapping("/updateMesh")
    @PreAuthorize("@ss.hasPermi('slope:mesh:updateMesh')")
    public AjaxResult updateMesh(@RequestBody SlopeMesh slopeMesh)
    {
        return toAjax(slopeMeshService.updateSlopeMesh(slopeMesh));
    }

    /**
     * 删除三维模型
     */
    @ApiOperation("删除三维模型")
    @Log(title = "监测管理", businessType = BusinessType.DELETE)
	@PostMapping("/{meshIds}")
    @PreAuthorize("@ss.hasPermi('slope:mesh:remove')")
    public AjaxResult remove(@PathVariable Long[] meshIds)
    {
        return toAjax(slopeMeshService.deleteSlopeMeshByIds(meshIds));
    }
}
